package com.qf.oa_system.service.impl;

import com.qf.oa_system.entity.Weekly;
import com.qf.oa_system.mapper.WeeklyDao;
import com.qf.oa_system.service.WeeklyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * ?ܱ??(Weekly)表服务实现类
 *
 * @author makejava
 * @since 2020-06-03 20:26:32
 */
@Service("weeklyService")
public class WeeklyServiceImpl implements WeeklyService {
    @Resource
    private WeeklyDao weeklyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param weekId 主键
     * @return 实例对象
     */
    @Override
    public Weekly queryById(Integer weekId) {
        return this.weeklyDao.queryById(weekId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Weekly> queryAllByLimit(int offset, int limit) {
        return this.weeklyDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param weekly 实例对象
     * @return 实例对象
     */
    @Override
    public Weekly insert(Weekly weekly) {
        this.weeklyDao.insert(weekly);
        return weekly;
    }

    /**
     * 修改数据
     *
     * @param weekly 实例对象
     * @return 实例对象
     */
    @Override
    public Weekly update(Weekly weekly) {
        this.weeklyDao.update(weekly);
        return this.queryById(weekly.getWeekId());
    }

    /**
     * 通过主键删除数据
     *
     * @param weekId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer weekId) {
        return this.weeklyDao.deleteById(weekId) > 0;
    }

    @Override
    public List<Weekly> queryAll(Weekly weekly) {
        return weeklyDao.queryAll(weekly);
    }

    @Override
    public List<Weekly> queryByStuId(Integer userId) {
        return weeklyDao.queryByStuId(userId);
    }
}